<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/WEB-INF/template/globalTemplate.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:t="http://myfaces.apache.org/tomahawk"
                xmlns:opif="http://www.opif.com/formathlon/jsf/tags">


    <ui:define name="title">#{msg['application.titre.utilisateur.inscription']}</ui:define>


    <ui:define name="ariane">
        <h:commandLink action="/faces/index.xhtml"  
                       value="#{msg['application.titre.accueil']}"/>
        >
        #{msg['application.titre.utilisateur.inscription']}
    </ui:define>


    <ui:define name="content">

        <h:panelGroup styleClass="titre">Gestion des inscriptions</h:panelGroup>
        La liste ci-dessous répertorie l'ensemble des sessions pour lesquelles vous participez.<br/><br/>

        <p:dataTable var="uneInscription" value="#{userInscriptionBean.listInscription}"
                     emptyMessage="#{msg['application.emptyMessage']}"
                     id="dataTableInscription">  

            <p:column headerText="Formation" >  
                <h:outputText value="#{uneInscription.session.formation.domaine.libelle} - #{uneInscription.session.formation.libelle}" />  
            </p:column> 

            <p:column headerText="Période" >  
                <h:outputText value="#{uneInscription.session.dateDebut}">
                    <f:convertDateTime pattern="dd/MM/yy"/>
                </h:outputText>
                -
                <h:outputText value="#{uneInscription.session.dateFin}" >
                    <f:convertDateTime pattern="dd/MM/yy"/>
                </h:outputText>
            </p:column>

            <p:column headerText="Etat" >
                <h:outputText value="#{uneInscription.etat.libelle}" />
            </p:column>

            <p:column headerText="Actions" >
                <p:commandLink action="#{userInscriptionBean.supprimer(uneInscription)}"
                               value="Supprimer "
                               update="globalForm inscrit messages"
                               rendered="#{userInscriptionBean.canSupprimer(uneInscription)}"
                               />
                <p:commandLink action="#{userInscriptionBean.desister(uneInscription)}"
                               value="Désister "
                               update="globalForm:popup"
                               rendered="#{userInscriptionBean.canDesister(uneInscription)}"
                               />

                <p:commandLink action="#{userInscriptionBean.annuler(uneInscription)}"
                               value="Annuler "
                               update="popup dataTableInscription messages globalForm:confirm" ajax="false"
                               rendered="#{userInscriptionBean.canAnnuler(uneInscription)}"
                               />
            </p:column>

        </p:dataTable>

        <t:panelGroup rendered="#{loginControler.isChefCours() and not empty userInscriptionBean.listInscriptionSub}">
            <br/><p:separator title="Liste des sessions de l'ensemble de vos personnels."/><br/>
            Liste des sessions de l'ensemble de vos personnels.<br/><br/>
            <p:dataTable var="uneInscriptSub" value="#{userInscriptionBean.listInscriptionSub}"
                         emptyMessage="#{msg['application.emptyMessage']}" id="dataTableInscriptionSub">  

                <p:column headerText="Formation" >  
                    <h:outputText value="#{uneInscriptSub.session.formation.domaine.libelle} - #{uneInscriptSub.session.formation.libelle}" />  
                </p:column> 

                <p:column headerText="Personnel" >  
                    <h:outputText value="#{uneInscriptSub.personnel}" converter="#{personnelAttestConverter}" />  
                </p:column>

                <p:column headerText="Période" >  
                    <h:outputText value="#{uneInscriptSub.session.dateDebut}">
                        <f:convertDateTime pattern="dd/MM/yy"/>
                    </h:outputText>
                    -
                    <h:outputText value="#{uneInscriptSub.session.dateFin}" >
                        <f:convertDateTime pattern="dd/MM/yy"/>
                    </h:outputText>
                </p:column>

                <p:column headerText="Etat" >
                    <h:outputText value="#{uneInscriptSub.etat.libelle}" />
                </p:column>

                <p:column headerText="Actions" >
                    <p:commandLink value="Désister "   
                                   rendered="#{userInscriptionBean.canDesister(uneInscriptSub)}"
                                   action="#{userInscriptionBean.desister(uneInscriptSub)}"
                                   update="popup dataTableInscriptionSub" ajax="false"/>
                    <p:commandLink value="Annuler "   
                                   action="#{userInscriptionBean.annuler(uneInscriptSub)}"
                                   rendered="#{userInscriptionBean.canAnnuler(uneInscriptSub)}"
                                   update="dataTableInscriptionSub globalForm:confirm"/>
                </p:column>
            </p:dataTable>
        </t:panelGroup>
    </ui:define>

    <ui:define name="popup">
        <h:panelGrid columns="3">
            <h:outputLabel for="inputMotif" value="Motif"/>
            <p:inputTextarea value="#{userInscriptionBean.motif}" id="inputMotif"
                             />
            <p:message for="inputMotif"/>
        </h:panelGrid>

        <h:panelGrid columns="2">
            <opif:validationButton rendered="true" libelleValidation="Valider"
                                   managedBean="#{userInscriptionBean}"
                                   actionValidation="validerDesister"
                                   onclick="popup.hide()"
                                   update="globalForm messages"/>
        </h:panelGrid>
    </ui:define>
</ui:composition>
